package com.hilaver.dzmis;

import java.util.Comparator;
import java.util.Locale;

public class Constants {
	
	public final static String XML_RESPONSE_TYPE = "text/xml;charset=utf-8";
	public final static String HTML_RESPONSE_TYPE = "text/html;charset=utf-8";
	public final static String PDF_RESPONSE_TYPE = "application/pdf;charset=utf-8";
	public final static String ENCODING = "utf-8";
	public final static String XML_DOC_DEFINE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	public final static String[] XML_ROOT_TAG = new String[]{"<dzmis>", "</dzmis>"};
	public final static String[] XML_LOCALE_TAG = new String[]{"<locale>", "</locale>"};
	public final static String[] XML_CODE_TAG = new String[]{"<code>", "</code>"};
	public final static String[] XML_DESCRIPTION_TAG = new String[]{"<description>", "</description>"};
	public final static String[] XML_CDATA = new String[]{"<![CDATA[", "]]>"};
	public final static String[] XML_ITEM_TAG = new String[]{"<item>", "</item>"};
	public final static String[] XML_INDEX_TAG = new String[]{"<index>", "</index>"};
	public final static String[] XML_ITEM_TOTAL_TAG = new String[]{"<itemTotal>", "</itemTotal>"};
	public final static String[] XML_CURRENT_PAGE_TAG = new String[]{"<pageIndex>", "</pageIndex>"};
	
	public final static String SESSION_VALIDATING_CODE = "session.validating.code";
	public final static String SESSION_USER = "session.ueser";
	public final static String SESSION_ACTION_LIST = "session.actionlist";
	public final static String SESSION_ACTION_NAME_LIST = "session.actionnamelist";
	public final static String SESSION_LOCALE = "session.locale";
	
	// language type
	public final static Locale LOCALE_TYPE_FR = new Locale(Locale.FRANCE
			.getLanguage(), Locale.FRANCE.getCountry()); // French
	public final static Locale LOCALE_TYPE_ZH = new Locale(Locale.CHINA
			.getLanguage(), Locale.CHINA.getCountry()); // Chinese
	public final static Locale LOCALE_TYPE_EN = new Locale(Locale.US
			.getLanguage(), Locale.US.getCountry()); // English
	
	public final static String KEY_SEPARATOR = "-";
	
	public final static int PAGE_SIZE = 20;
	
	public final static String ORDER_ASC = "asc";
	
	public final static String ORDER_DESC = "desc";
	
	public static final Integer TOTAL_SCALE = 2;
	
	public class StrComparator implements Comparator{

		public int compare(Object arg0, Object arg1) {
			String str1 = (String)arg0;
			String str2 = (String)arg1;
			try{
				Integer i1 = Integer.parseInt(str1);
				Integer i2 = Integer.parseInt(str2);
				if(i1 > i2){
					return 1;
				}else if(i1 < i2){
					return -1;
				}else{
					return 0;
				}
			}catch(Exception e){
				return str1.compareTo(str2);
			}
		}
	}


}
